package com.badlogic.androidgames.framework;

import com.badlogic.androidgames.framework.math.Rectangle;
import com.badlogic.androidgames.framework.math.Vector2;
import com.badlogic.androidgames.stringutil.MyString;

public class MyMovableLabel {
	public enum type {ANCORATA, FISSA, TRASCINABILE};
	
	public boolean inMovement;
	public float width, height;
	
	public float xTouchDown, yTouchDown;
	
    public Vector2 position;
    public Rectangle bounds;
    
    public float xText, yText;
    
    public double touchDownStart = 0.0;
    public boolean touchDownFlag = false;
    
    public type labelType;
    
 	public MyString text = new MyString(2,11);
    
	public boolean complete;
	
	public boolean userCompletation;
	public boolean edited;
	
	public boolean enabled;
	
	public MyLine line;
    
    public MyMovableLabel(float x, float y, float width, float height, MyLine line) {
    	
        this.position = new Vector2(x,y);
        this.width = width;
        this.height = height; 
        this.bounds = new Rectangle(x-width/2, y-height/2, width, height);

        this.inMovement = false;
        this.xTouchDown = 0.0f; 
     	this.yTouchDown = 0.0f;
     	
     	//xText = (x-(width/2))+(0.07f*width);//usato con 3 linee
     	xText = (x-(width/2))+22;
     	//yText = (y+(0.26f*height)); //usato con 3 linee
     	yText = y+10; //usato con due linee
     	
     	complete = false;
     	
     	userCompletation = false;
     	edited = false;
     	
     	this.line = line;
    }
    
    //quando la trascino
    public void translateTo(float x, float y)
    {
    	this.position.x = this.position.x + (x - this.xTouchDown);
    	this.position.y = this.position.y + (y - this.yTouchDown);
    	this.bounds.lowerLeft.x = this.bounds.lowerLeft.x + (x - this.xTouchDown);
    	this.bounds.lowerLeft.y = this.bounds.lowerLeft.y + (y - this.yTouchDown);
    	this.xText = this.xText + (x - this.xTouchDown);
    	this.yText = this.yText + (y - this.yTouchDown);
    	
    	this.xTouchDown = x;
    	this.yTouchDown = y;
    }
    
    //quando la sposto attraverso la linea
    public void translateAt(float x, float y)
    {
    	this.bounds.lowerLeft.x = this.bounds.lowerLeft.x + (x - this.position.x);
    	this.bounds.lowerLeft.y = this.bounds.lowerLeft.y + (y - this.position.y);
    	this.xText = this.xText + (x - this.position.x);
    	this.yText = this.yText + (y - this.position.y);
    	this.position.x = x;
    	this.position.y = y;	
    }
    
    public void setTouchDownPosition(float x, float y)
    {
    	this.xTouchDown = x; 
     	this.yTouchDown = y;
    }
}
